#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e6 + 100;
ll a[10] = {0, 1};

bool dp[maxn];
bool book[10];

void dfs(int k) {
    if (k >= 10) {
        dp[inner_product(a + 1, a + 10, book + 1, 0)] = true;
        return;
    }
    book[k] = false;
    dfs(k + 1);
    book[k] = true;
    dfs(k + 1);


}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    for (int i = 2; i <= 9; i++)a[i] = a[i - 1] * i;
    dfs(1);
    int m;
    cin >> m;
    while (m--) {
        int x;
        cin >> x;
        cout << (dp[x] ? "Yes" : "No") << endl;
    }
    return 0;
}